# -*- coding: utf8-*-

import urllib2
import sys
import urllib
import cookielib
import base64
import re
import json
import hashlib

url2 = "http://weixin.sogou.com/weixin?query=mooc&fr=sgsearch&type=1&w=01019900&sut=1077&sst0=1433904126607&lkt=3%2C1433904125530%2C1433904125967"
# url = 'http://weixin.sogou.com/gzh?openid=oIWsFt5l9RDYeAjdXZBYtGzbH0JI'
url = 'http://weixin.sogou.com/'
print url
# 创建持久化cookies
'''
jar=cookielib.LWPCookieJar()#创建cookie容器实例
cookie_support= urllib2.HTTPCookieProcessor(jar)#将容器与http的cookie处理器绑定
opener=urllib2.build_opener(cookie_support,urllib2.HTTPHandler)#handler用于处理http的URL的打开
urllib2.install_opener(opener)
'''
headers = {"headers":'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36' }
data = {'SUID': 'C2157C7B1541900A5549C6270007CFC3', 'YYID': '44DB11419CB35BC54210196116A487FE',
    'SMYUV': '1430906854748904', 'IPLOC': 'CN1100', 'SUV': '00F43B2B7B7C15C2554AF6D66165E041',
    'ABTEST': '0|1431660268|v1', 'weixinIndexVisited': '1', 'ssuid': '5799031880',
    'CXID': '1D45688102866B222F8E2D30354D34E5',
    'ad': 'Klllllllll2qvtYXlllllVqTOzUlllllWTZqZkllllGllllljklll5@@@@@@@@@@',
    'SNUID': '6BBFD6D1A9ACB289AF35780CAA067225',
    'ld': 'gZllllllll2qqlI9lllllVqTOTylllllWTZqZkllllwllllljA7ll5@@@@@@@@@@', '_ga': 'GA1.2.1345431679.1433900830',
    'sct': '5', 'PHPSESSID': 'kh7mjt683d4huq41jevnb8ph80', 'SUIR': '6BBFD6D1A9ACB289AF35780CAA067225',
    
    'seccodeRight': 'success', 'LSTMV': '780%2C80', 'LCLKINT': '45680', }
data = urllib.urlencode(data)  # data需要转换格式

req = urllib2.Request(url2, data, headers)

c = urllib2.urlopen(req)
x = c.read()

print x
print c.info()
print c.getcode()
print c.geturl()


# c = urllib2.urlopen(url)
# x=c.read()
# print x
# print c.info()
# print c.getcode()
# print c.geturl()

